<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>

</body>
<script>


//类数组
//特征: 有数组的length属性,还可以通过索引获取数据
/*
let o = {
  0: 'a',
  1: 'b',
  length: 2
}
*/

//可迭代对象
/*
Object.defineProperty(o, 'length', {
  enumerable: false
})
for(let key in o){
  console.log(key, o[key])
}
*/

//新建数组
//方式1-字面量
// let a = [1,2,3]
//方式2-构造函数
// let a = new Array(1,2,3)
// let a = Array(1,2,3)
/*
let a = Array(3)//长度为3的空数组,不可以迭代,有缺陷的数组
a.forEach(t=>{
  console.log(t)
})
*/

//https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/from
//Array.from() 方法对一个类似数组或可迭代对象创建一个新的，浅拷贝的数组实例。
//用途:把类数组/存在缺陷的数组(不可以迭代)转换真数组
//特征:Array.from(伪数组/Array)返回真数组
/*
Array.from({length: 11}).forEach((t,i)=>{
  // console.log(t, i)
})
Array.from(Array(11)).forEach((t,i)=>{
  console.log(t, i)
})
*/
let currentYear = (new Date()).getFullYear()
// let yearList = Array.from(Array(11)).map((t,i)=> currentYear+i-5)
let yearList = Array.from(Array(11), (t,i)=> currentYear+i-5)
console.log(yearList)
</script>
</html>
